package p2p.tracker.client;

import java.net.InetAddress;

public class Client {

	private InetAddress inetAddress;
	private String ip;

	public InetAddress getInetAddress() {
		return inetAddress;
	}

	public void setInetAddress(InetAddress inetAddress) {
		this.inetAddress = inetAddress;
	}

	public Client(InetAddress inetAddress) {
		this.inetAddress = inetAddress;
	}
	
	public Client(String ip) {
		this.ip = ip;
	}
	
	public Client(byte[] arr) {
		this.ip = "";
		for (byte i : arr) {
			this.ip += String.valueOf(i) + ".";
		}
		this.ip = this.ip.substring(0, this.ip.length() - 1);
	}

	public byte[] getBytes() {
		byte[] b_ip = new byte[4];
		String[] arr = ip.split(".");
		int i = 0;
		for (String s : arr) {
			b_ip[i] = Byte.parseByte(s);
			i++;
		}

		return b_ip;

	}

}
